
Ext.onReady(function(){
	new MyApp.view.view();
	var un=document.getElementById('usernamediv').innerHTML;	
	Ext.getCmp('username').setValue(un);
});

//这句话要替换view里面那句html
//html: '您的用户名是：'+document.getElementById('usernamediv').innerHTML+'<br/>\r\n您的密码是：'+document.getElementById('passworddiv').innerHTML+'<br/>\r\n您的用户类型是：'+document.getElementById('userclassdiv').innerHTML+'',

Ext.define('MyApp.view.view', {
    extend: 'Ext.panel.Panel',

    frame: true,
    height: 555,
    id: 'view',
    renderTo: 'container_down',
    width: 1366,
    layout: {
        type: 'border'
    },
    header: false,
    title: 'My Panel',

    initComponent: function() {
        var me = this;

        Ext.applyIf(me, {
            items: [
                {
                    xtype: 'panel',
                    region: 'west',
                    frame: true,
                    width: 317,
                    title: '功能列表',
                    items: [
                        {
                            xtype: 'button',
                            handler: function(button, event) {
                                Ext.getCmp('gerenxinxi').setVisible(true);
                                Ext.getCmp('gerenxinxihead').setVisible(true);
                                Ext.getCmp('tabPanel').setActiveTab(0);
                            },
                            height: 26,
                            width: 318,
                            text: '查看个人信息'
                        },
                        {
                            xtype: 'button',
                            handler: function(button, event) {
                                Ext.getCmp('xiugaigerenxinxi').setVisible(true);
                                Ext.getCmp('xiugaigerenxinxihead').setVisible(true);
                                Ext.getCmp('tabPanel').setActiveTab(1);
                            },
                            height: 26,
                            width: 318,
                            text: '修改个人信息'
                        }
                    ]
                },
                {
                    xtype: 'tabpanel',
                    region: 'center',
                    id: 'tabPanel',
                    activeTab: 0,
                    items: [
                        {
                            xtype: 'panel',
                            frame: true,
html: '您的用户名是：'+document.getElementById('usernamediv').innerHTML+'<br/>\r\n您的密码是：'+document.getElementById('passworddiv').innerHTML+'<br/>\r\n您的用户类型是：'+document.getElementById('userclassdiv').innerHTML+'',
                            id: 'gerenxinxi',
                            width: 1037,
                            title: '个人信息',
                            tabConfig: {
                                xtype: 'tab',
                                id: 'gerenxinxihead'
                            }
                        },
                        {
                            xtype: 'panel',
                            frame: true,
                            id: 'xiugaigerenxinxi',
                            layout: {
                                type: 'absolute'
                            },
                            title: '修改个人信息',
                            tabConfig: {
                                xtype: 'tab',
                                id: 'xiugaigerenxinxihead'
                            },
                            items: [
                                {
                                    xtype: 'form',
                                    x: -8,
                                    y: -9,
                                    border: false,
                                    frame: true,
                                    height: 530,
                                    id: 'changeForm',
                                    width: 1035,
                                    layout: {
                                        type: 'absolute'
                                    },
                                    bodyPadding: 10,
                                    header: false,
                                    title: 'My Form',
                                    items: [
                                        {
                                            xtype: 'button',
                                            handler: function(button, event) {
                                                Ext.getCmp('password').setValue(''); 
                                                Ext.getCmp('password2').setValue(''); 
                                            },
                                            x: 580,
                                            y: 260,
                                            height: 40,
                                            width: 140,
                                            text: '重置'
                                        },
                                        {
                                            xtype: 'button',
                                            handler: function(button, event) {
                                                if(Ext.getCmp('password').getValue()!=Ext.getCmp('password2').getValue()){
                                                    alert('两次输入的密码不一致！');
                                                }
                                                else{
                                                    Ext.Ajax.request({
                                                        url: './changeUserAction',
                                                        params:{
                                                            username:Ext.getCmp('username').getValue(),
                                                            password:Ext.getCmp('password').getValue()
                                                        },  
                                                        success: function(response, opts) {
                                                            document.getElementById('usernamediv').innerHTML=Ext.getCmp('username').getValue();
                                                            document.getElementById('passworddiv').innerHTML=Ext.getCmp('password').getValue();  
                                                            Ext.getCmp('gerenxinxi').body.update('您的用户名是：'+document.getElementById('usernamediv').innerHTML+'<br/>\r\n您的密码是：'+document.getElementById('passworddiv').innerHTML+'<br/>\r\n您的用户类型是：'+document.getElementById('userclassdiv').innerHTML+'');
                                                            alert('修改成功！');
                                                            Ext.getCmp('gerenxinxi').setVisible(true);
                                                            Ext.getCmp('gerenxinxihead').setVisible(true);
                                                            Ext.getCmp('tabPanel').setActiveTab(0);
                                                            Ext.getCmp('password').setValue(''); 
                                                            Ext.getCmp('password2').setValue('');        
                                                        }
                                                    });
                                                }
                                            },
                                            x: 380,
                                            y: 260,
                                            height: 40,
                                            width: 140,
                                            text: '确认'
                                        },
                                        {
                                            xtype: 'textfield',
                                            x: 360,
                                            y: 190,
                                            height: 32,
                                            id: 'password2',
                                            width: 380,
                                            fieldLabel: '请重复密码',
                                            labelWidth: 130,
                                            name: 'password2',
                                            inputType: 'password'
                                        },
                                        {
                                            xtype: 'textfield',
                                            x: 360,
                                            y: 140,
                                            height: 32,
                                            id: 'password',
                                            width: 380,
                                            fieldLabel: '请输入修改后的密码',
                                            labelWidth: 130,
                                            name: 'password',
                                            inputType: 'password'
                                        },
                                        {
                                            xtype: 'textfield',
                                            x: 360,
                                            y: 90,
                                            height: 32,
                                            id: 'username',
                                            width: 380,
                                            fieldLabel: '用户名',
                                            labelWidth: 130,
                                            name: 'username',
                                            readOnly: true
                                        }
                                    ]
                                }
                            ]
                        }
                    ]
                }
            ]
        });

        me.callParent(arguments);
    }

});